Skip to content

feat(validator): commit pending MIG-mode change via targeted GPU reset - #2603

Open
lexfrei wants to merge 1 commit into
NVIDIA:mainfrom
lexfrei:feat/validator-commit-mig-mode-gpu-reset
Open

feat(validator): commit pending MIG-mode change via targeted GPU reset#2603
lexfrei wants to merge 1 commit into
NVIDIA:mainfrom
lexfrei:feat/validator-commit-mig-mode-gpu-reset

Conversation

@lexfrei

@lexfrei lexfrei commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Description

RFC / DRAFT: opening for design feedback before the runtime path is exercised on GPU hardware. See the "Destructive GPU reset, why it is safe here" section below.

On Ampere (A100, A30) enabling MIG mode needs a GPU reset, and the driver tries that reset itself. It doesn't always work: the reset is refused while the GPU is in use, and under passthrough the hypervisor can disallow it. The GPU then sits with mig.mode.pending=Enabled and mig.mode.current not Enabled, so MIG-backed vGPU devices can't be created until something resets it later. Right now that means a hand-rolled host-side step.

This adds an opt-in step to vGPU Manager validation that commits such a pending enable with a targeted nvidia-smi --gpu-reset. It runs before the wait for SR-IOV VFs, and it skips any GPU that already has VFs.

What this is not: it does not recreate MIG state lost to a reboot, and it isn't needed for that. MIG mode survives a reboot on Ampere via an InfoROM status bit, and from Hopper on, enabling it no longer needs a reset. MIG instances don't survive on any generation, but recreating those is mig-parted's job.

Destructive GPU reset, why it is safe here

nvidia-smi --gpu-reset clears GPU hardware and software state; the manual describes it as a way to avoid a machine reboot. It does not tear down running work: nvidia-smi refuses the reset while any application is using the device, and the MIG guide says to kill those processes and retry. The step is off by default and gated because a validator should not do a privileged device-level operation implicitly, and because clearing device state breaks anything holding the GPU. It resets a GPU only when all of these hold:

  • Opt-in. New flag --commit-mig-mode-with-gpu-reset (env COMMIT_MIG_MODE_WITH_GPU_RESET), default false. Unset, behavior is identical to today: no reset, validate() unchanged.
  • vGPU path only. commitMIGMode is reached only from VGPUManager.validate(), which early-returns for non-vm-vgpu workloads.
  • MIG mode requested but not committed: mig.mode.pending == Enabled and mig.mode.current != Enabled. Something else already requested the change; this only commits it, never decides it.
  • No SR-IOV VFs enabled on that GPU.
  • No running compute processes. The probe is --query-compute-apps, so it only sees compute clients. nvidia-smi --gpu-reset refuses to reset a GPU while any application is using it, including the graphics and monitoring clients this query misses. The manual also says an individual reset may not be feasible while compute apps run on other GPUs; that comes back as a logged failure.

Enabling it

The flag reads its env var from the vgpu-manager validation init container, so the generic validator.env does not reach it: that one is applied to the main validator container. The key that works is validator.vgpuManager.env, which the chart templates and the operator forwards on case "vgpu-manager":

--set validator.vgpuManager.env[0].name=COMMIT_MIG_MODE_WITH_GPU_RESET \
--set validator.vgpuManager.env[0].value=true

That path works but is not discoverable. validator.vgpuManager is absent from values.yaml, which declares only env, args and plugin.env under validator, so the key never shows up in helm show values and an operator can only find it by reading the chart template. validator.vfioPCI and validator.vgpuDevices have the same gap. Happy to send a separate PR declaring all three if you want them discoverable.

In the steady state, MIG already committed or VFs present, it does nothing. Best-effort: reset failures are logged and validation continues, so setups that commit MIG mode out-of-band keep working as before.

Two open questions I'd rather raise than paper over, both discussed in #2600:

  • The VF guard is stated here as a precondition, but I can't source a rule that a GPU reset requires SR-IOV to be disabled first. It is not among the preconditions NVIDIA documents for nvidia-smi -r, and NVIDIA's own MIG recipes enable VFs before setting MIG mode. So the guard is observed behavior without a verified rationale.
  • On NVSwitch / Fabric Manager systems a single-GPU reset can interact with fabric partition state. This change only commits MIG mode and doesn't manage fabric partitions.

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Lint checks passing (make lint): the changed package is clean, GOOS=linux golangci-lint run ./cmd/nvidia-validator/ reports 0 issues. Repo-wide make lint was not run locally.
  • Generated assets in-sync (make validate-generated-assets): this change adds no API/CRD changes, so no generated assets change; the full target was not run.
  • Go mod artifacts in-sync (make validate-modules)
  • Test cases are added for new code paths

Testing

  • gofmt, go build, go vet, and golangci-lint run on the changed package, cross-compiled GOOS=linux (the validator is a Linux-only binary): clean, 0 issues. No asset or go.mod/go.sum changes.
  • New unit tests run green in a Linux container (go test ./cmd/nvidia-validator/): TestNormalizePCIAddress (nvidia-smi 8-digit vs go-nvlib 4-digit PCI domains normalize to the same key), TestParseMIGModes (CSV parsing, [N/A], malformed rows, the pending-vs-current guard), TestMIGModeNeedsCommit (the enable-only commit predicate across every current/pending combination, including case-insensitivity), and TestShouldResetForMIGCommit (the reset-decision guard matrix over uncommitted-enable, VFs-present and workload-running).
  • commitMIGMode itself has no test, including its off-by-default gate. That is the gap I'd fix first if this design survives the discussion in [Feature]: Persist MIG mode and SR-IOV vGPU VFs across reboot on the sandbox/vGPU path (operator-driven GPU reset) #2600.
  • Not yet exercised on GPU hardware; the runtime chroot / nvidia-smi --gpu-reset path relies on CI and cluster testing. This is why the PR is opened as a draft/RFC.

Refs #2600.

@copy-pr-bot

copy-pr-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@rajathagasthya

Copy link
Copy Markdown
Contributor

Just linking back to the ongoing discussion at #2600 (comment) (thanks for the additional context there!). Let's revisit this PR once we decide on a direction for #2600.

@lexfrei
lexfrei force-pushed the feat/validator-commit-mig-mode-gpu-reset branch from 7a40a92 to 95e02db Compare August 10, 2026 10:37
@lexfrei
lexfrei force-pushed the feat/validator-commit-mig-mode-gpu-reset branch from 95e02db to c08f31a Compare September 1, 2026 11:42
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an opt-in commit-mig-mode-with-gpu-reset flag. Validation detects pending MIG-mode enables, checks VF and process conditions, and resets eligible GPUs through nvidia-smi. The change adds PCI normalization, MIG CSV parsing, driver-path resolution, process checks, aggregated reset errors, and tests for these behaviors. Validation logs commit errors and continues.

Merge Risk: 🟡 Moderate · up to c08f3

The opt-in MIG commit path can report validation success after GPU discovery, MIG query, or reset failures, and it can ignore the configured driver root, preventing the targeted reset when the container path differs. That can leave pending MIG mode uncommitted and block creation of MIG-backed vGPU devices, so the PR is not merge-ready until these correctness issues are fixed or explicitly accepted.


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Team

Run ID: 7e1a4c59-2ac1-48c9-94d9-1a9c772c0d32

📥 Commits

Reviewing files that changed from the base of the PR and between f12acb8 and c08f31a.

📒 Files selected for processing (2)
  • cmd/nvidia-validator/main.go
  • cmd/nvidia-validator/main_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

// running compute work or fail to commit a pending MIG-mode enable. A reset is
// warranted only for an uncommitted MIG-mode enable on a GPU with no VFs and
// no running compute processes.
func TestShouldResetForMIGCommit(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Add a commitMIGMode regression test.

TestShouldResetForMIGCommit tests only the predicate. It does not test GPU enumeration, process-query failures, reset command selection, or aggregated reset errors in commitMIGMode.

Add an injected PCI and command boundary. Verify that eligible GPUs reset once, guarded GPUs never reset, and reset failures reach the caller. This prevents a regression that resets an ineligible GPU or skips an eligible reset.

As per path instructions: “Flag … new operand or CRD behaviour that ships with no regression test.”

Source: Path instructions

Comment on lines +1767 to +1768
if err := commitMIGMode(hostDriver); err != nil {
log.Warnf("Unable to commit pending MIG mode, continuing: %v", err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Return the MIG commit error.

If GPU discovery, MIG-mode query, or GPU reset fails, this path logs the error and continues as success. This suppresses retry of the pending MIG transition during validation and can leave the GPU uncommitted.

As per path instructions: “Flag an error that is logged and then returned as success. That suppresses the retry.”

Source: Path instructions

// and the WSL path).
func vgpuNvidiaSMI(hostDriver bool, hostRootCtrPath string) (driverRoot, nvidiaSMI string, err error) {
if !hostDriver {
return defaultDriverInstallDir, "nvidia-smi", nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use the configured container driver root.

When DRIVER_INSTALL_DIR_CTR_PATH differs from /run/nvidia/driver, vgpuNvidiaSMI returns the wrong chroot root. The MIG query then fails, validation logs the error, and the requested GPU reset does not run.

  • cmd/nvidia-validator/main.go#L1884-L1884: return driverInstallDirCtrPathFlag for container drivers.
  • cmd/nvidia-validator/main_test.go#L723-L727: set a non-default driverInstallDirCtrPathFlag and assert that vgpuNvidiaSMI returns it.

As per path instructions: “Flag assertions that would still pass if the behavior under test were broken.”

📍 Affects 2 files
  • cmd/nvidia-validator/main.go#L1884-L1884 (this comment)
  • cmd/nvidia-validator/main_test.go#L723-L727

Source: Path instructions

On NVIDIA Ampere GPUs (A100, A30), enabling MIG mode requires a GPU reset
and the driver attempts that reset itself. The attempt is refused while any
application is using the GPU, which leaves the card reporting
mig.mode.pending=Enabled with mig.mode.current not Enabled: the change is
requested but never applied, and MIG-backed vGPU devices cannot be created
until some later reset commits it. That is the window this addresses.

Add an opt-in step to vGPU Manager validation that commits such a
pending-but-uncommitted MIG-mode enable via a targeted
'nvidia-smi --gpu-reset'. It runs before validation waits for the vGPU
stack to come up; the reset is skipped while VFs are present.

The reset is destructive, so it is tightly gated: it runs only when
explicitly enabled (commit-mig-mode-with-gpu-reset, off by default), only
on the vGPU path, and only on a GPU whose MIG-mode enable is requested but
not yet applied, that has no SR-IOV VFs enabled, and that has no running
compute processes. It is best-effort: reset failures are logged and
validation continues, preserving current behavior for setups that commit
MIG mode by other means.

Scope: this commits a mode change that was already requested. It does not
recreate MIG devices, which do not survive a reboot and are recreated by
whatever manages the MIG layout, not by a reset. MIG mode itself is
persistent across reboots on Ampere via an InfoROM status bit, and from
Hopper onward enabling MIG mode no longer requires a GPU reset.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
@lexfrei
lexfrei force-pushed the feat/validator-commit-mig-mode-gpu-reset branch from c08f31a to f28c518 Compare September 1, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants